package com.ming_za.odupdaterserver.core.config.type;

import java.util.function.BiConsumer;
import java.util.function.Function;

/**
 * 详情请见{@link ValueType}
 */
public class IntValue extends ValueType<Integer>{

    public IntValue(String key, Function<String, String> getter, BiConsumer<String, String> setter) {
        super(key, getter, setter);
    }

    public IntValue(String key,Integer defaultValue, Function<String, String> getter, BiConsumer<String, String> setter) {
        super(key,defaultValue, getter, setter);
    }

    @Override
    protected Integer valueToObject(String value) {
        if (value == null){
            return null;
        }
        return Integer.parseInt(value);
    }

    @Override
    protected String objectToValue(Integer value) {
        if (value == null){
            return null;
        }
        return value.toString();
    }
}
